<%@ page import="com.graduation.lastproject.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2020/3/21
  Time: 10:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    String userPhone=request.getSession().getAttribute("userInfo")!=null ? ((User)request.getSession().getAttribute("userInfo")).getPhone() : "";
%>
<c:set var="ctx" value="<%=basePath%>"  />
<c:set var="userPhone" value="<%=userPhone%>"/>
<html>
<head>
    <title>订单操作</title>
    <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/toastr/toastr.min.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/bootstrap/js/bootstrap.min.js"></script>
    <script src="/static/js/home/mybookorder.js"></script>
    <script src="/static/toastr/toastr.min.js"></script>

    <style type="text/css">
        span{
            color:#008000;
            font-weight: 900;
        }
        /*只显示纵向滑动条*/
        html { overflow-x: hidden; overflow-y: auto; }
        .row{
            margin-left: 30px;
        }
        .table-striped > tbody > tr:nth-of-type(odd){
            background-color: lavender;
        }
        .table>tbody>tr{
            height:60px;
        }
    </style>
    <script>
        var ctx='${ctx}'
        var userPhone='${userPhone}';  //用户积分更新
    </script>
</head>
<body>
<div class="row">
    <div>
        <table  id="mytable"
                class="table table-striped table-hover table-condensed table-bordered">
            <thead>
               <tr>
                   <th>酒店信息</th>
                   <th>消费价格</th>
                   <th>付款时间</th>
                   <th>入住时间</th>
                   <th>退房时间</th>
                   <th>操作</th>
               </tr>
            </thead>
            <tbody>
            <c:forEach items="${pageInfo.list}" var="bookorder" varStatus="status">
                <tr class="infoPic${status.index}" >
                    <input type="hidden" id="id${status.index}" value="${bookorder.id}">
                    <td>${bookorder.hotelNameRoom}</td>
                    <td>${bookorder.total_price}</td>
                    <td>${bookorder.gmt_payment}</td>
                    <td>${bookorder.inTime}</td>
                    <td>${bookorder.outTime}</td>
                  <%--  <td><fmt:formatDate value="${bookorder.gmt_payment}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    <td><fmt:formatDate value="${bookorder.inTime}" pattern="yyyy-MM-dd"/></td>
                    <td><fmt:formatDate value="${bookorder.outTime}" pattern="yyyy-MM-dd"/></td>--%>
                    <td>
                        <div class="btn-group">
                            <button type="button" class="btn-primary btn" onclick="scanInfoOrder('${bookorder.out_trade_no}','${bookorder.bookuser}','${bookorder.book_user_phone}','${bookorder.peoples}')" style="margin-left: 10px" data-toggle="modal" data-target="#scanInfoModal">查看详情</button>
                            <c:choose>
                                <c:when test="${bookorder.reviewState != '1'}">
                                    <button type="button" class="btn-primary btn" onclick="reviewOrder('${bookorder.userPhone}','${bookorder.hotelId}','${bookorder.id}','${bookorder.hotelNameRoom}')" style="margin-left: 10px" data-toggle="modal" data-target="#reviewModal">评论</button>
                                </c:when>
                                <c:otherwise>
                                    <button type="button" class="btn-primary btn" onclick="reviewAddOrder('${bookorder.id}')" style="margin-left: 10px" data-toggle="modal" data-target="#reviewAddModal">追评</button>
                                </c:otherwise>
                            </c:choose>
                            <button type="button" class="btn btn-danger" onclick="deleteOrder('${bookorder.id}')" style="margin-left: 10px" data-toggle="modal" data-target="#deleteModal">删除</button>
                            <c:choose>
                                <c:when test="${bookorder.trade_state =='1'}">
                                    <button type="button" class="btn btn-danger"
                                            onclick="returnOrder('${bookorder.out_trade_no}','${bookorder.total_price}','${bookorder.id}','${bookorder.inTime}',
                                                    '${bookorder.hotelId}','${bookorder.hotelNameRoom}')"
                                            style="margin-left: 10px" data-toggle="modal" data-target="#returnModal">退款
                                    </button>
                                </c:when>
                                <c:otherwise>
                                    <button type="button" class="btn btn-danger"  style="margin-left: 10px" disabled>已退款</button>
                                </c:otherwise>
                            </c:choose>
                        </div>
                    </td>
                </tr>

            </c:forEach>
            </tbody>
        </table>
        <%--分页--%>
        <p>
            当前 <span>${pageInfo.pageNum}</span> 页,总 <span>${pageInfo.pages}</span> 页,共 <span>${pageInfo.total}</span> 条记录
        </p>
        <ul class="pagination">
            <li><a href="${ctx}homeHigh/mybookorder">第一页</a> </li>
            <c:choose>
                <c:when test="${pageInfo.hasPreviousPage == 'true'}">
                    <li><a href="${ctx}homeHigh/mybookorder?pageNum=${pageInfo.prePage}")>上一页</a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="${ctx}homeHigh/mybookorder?pageNum=1">上一页</a></li>
                </c:otherwise>
            </c:choose>
            <c:choose>
                <c:when test="${pageInfo.hasNextPage == 'true'}">
                    <li><a href="${ctx}homeHigh/mybookorder?pageNum=${pageInfo.nextPage}">下一页</a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="${ctx}homeHigh/mybookorder?pageNum=${pageInfo.pages}">下一页</a></li>
                </c:otherwise>
            </c:choose>
            <li><a href="${ctx}homeHigh/mybookorder?pageNum=${pageInfo.pages}">最后一页</a></li>
        </ul>
    </div>

    <%--删除模态框--%>
    <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="deleteModalLaber">删除框</h4>
                </div>
                <div class="modal-body" id="active">
                      <input type="hidden" name="deleteId" id="deleteId"/>
                      <span> 确定删除吗?</span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="deleteActive">删除</button>
                </div>
            </div>
        </div>
    </div>

    <%--评论模态框--%>
    <div class="modal fade" id="reviewModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="reviewlLabel">评论框</h4>
                </div>
                <div class="modal-body" >
                    <input type="hidden" name="orderId" id="orderId"/>
                    <input type="hidden" name="userPhone" id="userPhone"/>
                    <input type="hidden" name="hotelId" id="hotelId"/>
                    <input type="hidden" name="hotelNameRoom" id="hotelNameRoom"/>
                    <textarea class="form-control" rows="3" id="reviewAll" placeholder="请输入您的评价"></textarea>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="reviewActive">发表</button>
                </div>
            </div>
        </div>
    </div>

    <%--详情模态框--%>
    <div class="modal fade" id="scanInfoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="scanInfoModalLabel">详情框</h4>
                </div>
                <div class="modal-body" >
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label  class="col-md-3 control-label">订单号:</label>
                            <div class="col-md-8">
                                <input type="text" id="trade" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">入住人姓名:</label>
                            <div class="col-md-8">
                                <input type="text" id="bookuser" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">入住人电话:</label>
                            <div class="col-md-8">
                                <input type="text" id="bookuserPhone" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">入住人数:</label>
                            <div class="col-md-8">
                                <input type="text" id="peoples" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">预订间数:</label>
                            <div class="col-md-8">
                                <input type="text" value="1" class="form-control" />
                            </div>
                        </div>
                    </form>
                      <%--订单号:<input type="text" id="trade" class="form-control"><br>
                      入住人姓名:<input type="text" id="bookuser" class="form-control"><br>
                      入住人电话：<input type="text" id="bookuserPhone" class="form-control"><br>
                      入住人数：<input type="text" id="peoples" class="form-control"><br>
                      预订间数:<input type="text" value="1" class="form-control"><br>--%>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>

    <%--退款模态框--%>
    <div class="modal fade" id="returnModal" tabindex="-1" role="dialog" aria-labelledby="deleteModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="returnModalLaber">退款框</h4>
                </div>
                    <input type="hidden" name="out_trade_no" id="out_trade_no"/>
                    <input type="hidden" name="total_price" id="total_price"/>
                    <input type="hidden" name="returnOrderId" id="returnOrderId"/>
                    <input type="hidden" name="returnHotelId" id="returnHotelId"/>
                    <input type="hidden" name="hotelRoom" id="hotelRoom"/>
                    <label>退款金额</label>
                    <input type="text" disabled id="return_price">
                    <span> 确定退款吗?</span>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="returnActive">退款</button>
                </div>
            </div>
        </div>
    </div>

    <%--追加评论模态框--%>
    <div class="modal fade" id="reviewAddModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="reviewAddlLabel">评论框</h4>
                </div>
                <div class="modal-body" >
                    <input type="hidden" name="reviewAdd" id="reviewAdd"/>
                    <textarea class="form-control" rows="3" id="reviewAddAll" placeholder="请追加您的评价"></textarea>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="reviewAddActive">发表</button>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
</html>
